using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using RMSM;

namespace AC.Report
{
	public partial class TrangPhuc : DevExpress.XtraReports.UI.XtraReport
	{
		private LanTrangPhucBOCollection lanTrangPhucBOCollection = null;

		public TrangPhuc(string title, int HopDongID, CTTrangPhucBOCollection chiTietTrangPhucBOCollection, LanTrangPhucBOCollection lanTrangPhucBOCollection)
		{
			InitializeComponent();

			if (title == null)
				this.ReportHeader.Visible = false;
			else
				this.lblTitle.Text = title;

			if (lanTrangPhucBOCollection == null)
				this.lanTrangPhucBOCollection = LanTrangPhucBOCollection.GetLanTrangPhucBOCollection("HOPDONGID=" + HopDongID, "LANTRANGPHUCID");
			else
				this.lanTrangPhucBOCollection = lanTrangPhucBOCollection;

			this.lblGhiChu.SummaryGetResult += new SummaryGetResultHandler(lblGhiChu_SummaryGetResult);
			this.lblNgayThu.SummaryGetResult += new SummaryGetResultHandler(lblNgayThu_SummaryGetResult);
			this.lblNgayGiao.SummaryGetResult += new SummaryGetResultHandler(lblNgayGiao_SummaryGetResult);
			this.lblNgayTra.SummaryGetResult += new SummaryGetResultHandler(lblNgayTra_SummaryGetResult);


			this.bds.DataSource = chiTietTrangPhucBOCollection;
		}

		private void lblGhiChu_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanTrangPhucID = (int)GetCurrentColumnValue("LanTrangPhucID");
			LanTrangPhucBO lanTrangPhucBO = this.lanTrangPhucBOCollection.GetBO(LanTrangPhucID);
			e.Result = (string.IsNullOrEmpty(lanTrangPhucBO.GhiChu) ? "" : lanTrangPhucBO.GhiChu);
			e.Handled = true;
		}

		private void lblNgayThu_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanTrangPhucID = (int)GetCurrentColumnValue("LanTrangPhucID");
			LanTrangPhucBO lanTrangPhucBO = this.lanTrangPhucBOCollection.GetBO(LanTrangPhucID);
			if (lanTrangPhucBO.NgayThu == null)
				e.Result = "";
			else
				e.Result = lanTrangPhucBO.NgayThu.Value.ToString("dd/MM/yyyy  HH:mm");
			e.Handled = true;
		}

		private void lblNgayGiao_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanTrangPhucID = (int)GetCurrentColumnValue("LanTrangPhucID");
			LanTrangPhucBO lanTrangPhucBO = this.lanTrangPhucBOCollection.GetBO(LanTrangPhucID);
			if (lanTrangPhucBO.NgayGiao == null)
				e.Result = "";
			else
				e.Result = lanTrangPhucBO.NgayGiao.Value.ToString("dd/MM/yyyy  HH:mm");
			e.Handled = true;
		}

		private void lblNgayTra_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanTrangPhucID = (int)GetCurrentColumnValue("LanTrangPhucID");
			LanTrangPhucBO lanTrangPhucBO = this.lanTrangPhucBOCollection.GetBO(LanTrangPhucID);
			if (lanTrangPhucBO.NgayTra == null)
				e.Result = "";
			else
				e.Result = lanTrangPhucBO.NgayTra.Value.ToString("dd/MM/yyyy  HH:mm");
			e.Handled = true;
		}
	}
}
